package com.k8sops.backend.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.k8sops.backend.model.entity.DOSRelease;
import com.k8sops.backend.model.vo.ReleaseVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * DOSRelease Mapper接口
 */
@Mapper
public interface DOSReleaseMapper extends BaseMapper<DOSRelease> {
    
    /**
     * 分页查询Release列表，并关联项目和项目组信息
     * 
     * @param page 分页参数
     * @param queryWrapper 查询条件
     * @return 分页结果，包含项目和项目组信息
     */
    @Select("SELECT r.*, p.project_name, pg.group_name as project_group_name " +
           "FROM dos_release r " +
           "LEFT JOIN dos_project p ON r.project_id = p.id " +
           "LEFT JOIN dos_project_group pg ON p.group_id = pg.id " +
           "${ew.customSqlSegment}")
    IPage<ReleaseVO> selectReleasesWithProjectInfo(Page<ReleaseVO> page, @Param(Constants.WRAPPER) Wrapper<DOSRelease> queryWrapper);
}
